{% extends "base.html" %}
{% block content %}
<h2>{% if patient %}Edit Patient{% else %}Add New Patient{% endif %}</h2>
{% if error %}<p style="color:red">{{ error }}</p>{% endif %}
<form method="post">
  Name: <input name="name" value="{{ patient.name if patient else '' }}" required><br>
  Gender:
  <select name="gender">
    <option {% if patient and patient.gender=='男' %}selected{% endif %}>Male</option>
    <option {% if patient and patient.gender=='女' %}selected{% endif %}>Female</option>
  </select><br>
  Age: <input name="age" type="number" min="1" value="{{ patient.age if patient else '' }}" required><br>
  Phone: <input name="phone" value="{{ patient.phone if patient else '' }}" required><br>
  Email: <input name="email" value="{{ patient.email if patient else '' }}"><br>
  Address: <input name="address" value="{{ patient.address if patient else '' }}"><br>
  Medical History: <textarea name="medical_history">{{ patient.medical_history if patient else '' }}</textarea><br>
  <button type="submit">Save</button>
</form>
{% endblock %}
